package com.heima.controller;

import com.heima.pojo.Type;
import com.heima.pojo.dto.PagingQueryDTO;
import com.heima.pojo.vo.PagingVO;
import com.heima.service.TypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//设备类型管理
@RestController
@RequestMapping("/api/vm-service/vmType")
@Slf4j
public class TypeController {
    @Autowired
    private TypeService typeService;
    //查询设备
    @GetMapping("/search")
    private PagingVO slectType(PagingQueryDTO receiveDto){
        log.info("查看设备类型{}",receiveDto);
        return typeService.slectType(receiveDto);

    }
    //新增设备
    @PostMapping
    private Boolean addType( @RequestBody Type type){
        log.info("新增设备类型{}",type);
        return typeService.addType(type);
    }
    //修改设备类型
    @PutMapping("/{typeId}")
    private Boolean updateType(@PathVariable Long typeId,@RequestBody Type type){
        log.info("修改设备类型{}",type);
        return typeService.updateType(typeId,type);
    }
    //删除设备
    @DeleteMapping("/{typeId}")
    private Boolean deleteType(@PathVariable Long typeId){
        log.info("删除设备类型{}",typeId);
        return typeService.deleteType(typeId);
    }
}
